package com.cell.service.location.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cell.pojo.entity.location.City;
import com.cell.dao.location.CityDao;
import com.cell.service.location.ICityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cell.service.location.IProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author cloudJiang
 * @since 2022-06-04
 */
@Service
public class CityServiceImpl extends ServiceImpl<CityDao, City> implements ICityService {
    @Autowired
    IProvinceService provinceService;
    @Autowired
    CityDao cityDao;


    @Override
    public List<Object> getCityByProvinceName(String provinceName) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("name", provinceName);
        Integer provinceId = provinceService.getBaseMapper().selectOne(wrapper).getId();

        wrapper.clear();
        wrapper.select("name");
        wrapper.eq("province_id", provinceId);
        List<Object> objects = cityDao.selectObjs(wrapper);
        return objects;
    }
}
